import PKRequest from './request/index'
import { BASE_URL, TIME_OUT } from './config/index'

// 可以创建一个实例，也可以创建多个实例
const pkRequest = new PKRequest({
  baseURL: BASE_URL,
  timeout: TIME_OUT,
  interceptors: {
    requestOnFulfilledFn: (config) => {
      console.log('实例：请求成功的拦截')
      return config
    },
    requestOnRejectedFn: (err) => {
      console.log('实例：请求失败的拦截')
      return err
    },
    responseOnFulfilledFn: (res) => {
      console.log('实例：响应成功的拦截')
      return res.data
    },
    responseOnRejectedFn: (err) => {
      console.log('实例：响应失败的拦截')
      return err
    }
  }
})

export default pkRequest
